 var str="";
 
   str= getvl("chanshu");
   var strs=str.split(",");
   
 var userid=getvl("userid");
 $(function(){
 	weihuofabu(str);
 });
 
 
function weihuofabu(str){
    	$("#fabuweihuo").html("");
    	 $.ajax({
      url: urlcore + "/api/goods/selectgoodsAllag?str="+str,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					var sun=1;
					//alert(JSON.stringify(data.data));
					$.each(data.data, function(y,n) {
				var fabuweihuo='<div class="clearfix add_goods">'+
'		<div class="public-xuanze fl" >'+
'			<img src="images/delete.png" onclick="removeByValues('+n.id+')" width="20" height="20" />'+
'		</div>'+
'		<div class="clearfix tuwen">'+
'	    	<a href="javascript:void(0);">'+
'		        <div class="tuwen-img fl">'+
'		            <img onerror="errorImg(this)" src="'+n.coverUrl+'" width="75" height="75">'+
'		        </div>'+
'		        <div class="tuwen-wenzi">'+
'		            <h5 class="wuye_h01">'+n.goodsTitle+'</h5>'+
'		            <div class="wuye_div02">&yen;'+n.packPrice+'<span id="'+n.id+'" name="'+n.packPrice+'" class="P-tuifei">修改价格</span><input type="hidden" value="'+n.total+'"></div>'+
'		        </div>'+
'	        </a>'+
'	    </div>'+
'	</div>';
                 $("#fabuweihuo").append(fabuweihuo);
					});
					$(function(){
						  $(".P-tuifei").on('click',function(){
                  $("body").append("<div id='mask'></div>");
                   var goodsids= $(this).attr("id");
                   var moyli=$(this).attr("name");
                    var num=$(this).next().val();
                   $(".sell-xiugai33").find("#kuchun").val(num);
                    $(".sell-xiugai33").find("#shangpingid").val(goodsids);
                    $(".sell-xiugai33").find("#jiage").val(parseFloat(moyli));
                    $(".sell-xiugai33").show();
                 })
    //点击关闭
                  $(".show2_anniu span").on('click',function(){
                    $(".sell-xiugai33").hide();
                    $("#mask").remove();
                }) 
					})
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}
			},
			error: function() {
				alert("error");
			}
		});	
}
 //提交
   function tijiaos(){
   	var sts=strs.toString();
   //	alert(userid+".."+sts)
   	   	if(userid!=''){
    	 $.ajax({
      url: urlcore + "/api/poop2/addPoop2?atr2="+sts+"&userids="+userid,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					alert("已提交");
               window.location.href = "4.5.0weihuo.html";   //跳转列表页
               
				} else if(data.code == 'OVERTIME') {
					var thisUrl = window.location.href;
					alert(thisUrl);
					if(thisUrl.indexOf('1.0.0denglu.html') <= -1) {
						top.window.location.href = "1.0.0denglu.html";
					}
				} else {
					if(data.msg != '空数据') {
						alert(data.msg)
					} else {
						$('#thiscount').text(0);
					}
				}
			},
			error: function() {
				alert("error");
			}
		});	

   	   		
   	   	}else{
 		alert("未登录");
 	window.location.href = "1.0.0denglu.html";
}
   }
   
   
   



//删除数组元素
function removeByValues(val) {
	//alert(val);
  removeByValue(strs,val);
    strs.toString();
 //alert(strs.toString())
  weihuofabu(strs);
}



  function querenxiugai(){
  	        var kunchun=parseInt($("#kuchun").val());
  	         if(kunchun%1!=0){
  	         	alert("库存请输入整数");
  	         }else{
  	        var shangpingida=$("#shangpingid").val();
  	        
  	        var jiage=$("#jiage").val();
  	        if(jiage!="" && uuuuid!="" && shangpingida!=""){
	    $.ajax({  
        url : urlcore + "/api/poop/update",
        type : "post",  
        contentType: "application/json;charset=utf-8",
        data : JSON.stringify({
        	id:shangpingida,
        	packPrice:jiage,
        	total:kunchun
        }),
        	dataType: "json",
        success: function(data) {//data是返回的hash,key之类的值，key是定义的文件名 
        	var d=window.location.href;
        	window.location.href=d;
        },
        error:function(){  
            alert("修改失败");  
        }  
    });     
	     }
		}
		 
  }
